var jscolor, colorPrePath = "../../";

null != $("#skin").attr("prePath") && (colorPrePath = $("#skin").attr("prePath")), 
jQuery.fn.extend({
    colorRender: function() {
        return this.each(function() {
            new jscolor.color($(this)[0]);
        });
    }
}), jscolor = {
    dir: "",
    bindClass: "color",
    binding: !0,
    preloading: !0,
    install: function() {
        jscolor.addEvent(window, "load", jscolor.init);
    },
    init: function() {
        jscolor.binding && jscolor.bind(), jscolor.preloading && jscolor.preload();
    },
    getDir: function() {
        if (!jscolor.dir) {
            var a = jscolor.detectDir();
            jscolor.dir = a !== !1 ? a : "jscolor/";
        }
        return jscolor.dir;
    },
    detectDir: function() {
        var c, d, e, a = location.href, b = document.getElementsByTagName("base");
        for (c = 0; c < b.length; c += 1) b[c].href && (a = b[c].href);
        for (b = document.getElementsByTagName("script"), c = 0; c < b.length; c += 1) if (b[c].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(b[c].src)) return d = new jscolor.URI(b[c].src), 
        e = d.toAbsolute(a), e.path = e.path.replace(/[^\/]+$/, ""), e.query = null, e.fragment = null, 
        e.toString();
        return !1;
    },
    bind: function() {
        var i, m, prop, matchClass = new RegExp("(^|\\s)(" + jscolor.bindClass + ")\\s*(\\{[^}]*\\})?", "i"), e = document.getElementsByTagName("input");
        for (i = 0; i < e.length; i += 1) if (!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
            if (prop = {}, m[3]) try {
                eval("prop=" + m[3]);
            } catch (eInvalidProp) {}
            e[i].color = new jscolor.color(e[i], prop);
        }
    },
    preload: function() {
        for (var a in jscolor.imgRequire) jscolor.imgRequire.hasOwnProperty(a) && jscolor.loadImage(a);
    },
    images: {
        pad: [ 181, 101 ],
        sld: [ 16, 101 ],
        cross: [ 15, 15 ],
        arrow: [ 7, 11 ]
    },
    imgRequire: {},
    imgLoaded: {},
    requireImage: function(a) {
        jscolor.imgRequire[a] = !0;
    },
    loadImage: function(a) {
        jscolor.imgLoaded[a] || (jscolor.imgLoaded[a] = new Image(), jscolor.imgLoaded[a].src = colorPrePath + "libs/images/formEle/" + a);
    },
    fetchElement: function(a) {
        return "string" == typeof a ? document.getElementById(a) : a;
    },
    addEvent: function(a, b, c) {
        a.addEventListener ? a.addEventListener(b, c, !1) : a.attachEvent && a.attachEvent("on" + b, c);
    },
    fireEvent: function(a, b) {
        var c;
        a && (document.createEventObject ? (c = document.createEventObject(), a.fireEvent("on" + b, c)) : document.createEvent ? (c = document.createEvent("HTMLEvents"), 
        c.initEvent(b, !0, !0), a.dispatchEvent(c)) : a["on" + b] && a["on" + b]());
    },
    getElementPos: function(a) {
        var b = a, c = a, d = 0, e = 0;
        if (b.offsetParent) do d += b.offsetLeft, e += b.offsetTop; while (b = b.offsetParent);
        for (;(c = c.parentNode) && "BODY" !== c.nodeName.toUpperCase(); ) d -= c.scrollLeft, 
        e -= c.scrollTop;
        return [ d, e ];
    },
    getElementSize: function(a) {
        return [ a.offsetWidth, a.offsetHeight ];
    },
    getMousePos: function(a) {
        return a || (a = window.event), "number" == typeof a.pageX ? [ a.pageX, a.pageY ] : "number" == typeof a.clientX ? [ a.clientX + document.body.scrollLeft + document.documentElement.scrollLeft, a.clientY + document.body.scrollTop + document.documentElement.scrollTop ] : void 0;
    },
    getViewPos: function() {
        return "number" == typeof window.pageYOffset ? [ window.pageXOffset, window.pageYOffset ] : document.body && (document.body.scrollLeft || document.body.scrollTop) ? [ document.body.scrollLeft, document.body.scrollTop ] : document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop) ? [ document.documentElement.scrollLeft, document.documentElement.scrollTop ] : [ 0, 0 ];
    },
    getViewSize: function() {
        return "number" == typeof window.innerWidth ? [ window.innerWidth, window.innerHeight ] : document.body && (document.body.clientWidth || document.body.clientHeight) ? [ document.body.clientWidth, document.body.clientHeight ] : document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ? [ document.documentElement.clientWidth, document.documentElement.clientHeight ] : [ 0, 0 ];
    },
    URI: function(a) {
        function b(a) {
            for (var c, b = ""; a; ) "../" === a.substr(0, 3) || "./" === a.substr(0, 2) ? a = a.replace(/^\.+/, "").substr(1) : "/./" === a.substr(0, 3) || "/." === a ? a = "/" + a.substr(3) : "/../" === a.substr(0, 4) || "/.." === a ? (a = "/" + a.substr(4), 
            b = b.replace(/\/?[^\/]*$/, "")) : "." === a || ".." === a ? a = "" : (c = a.match(/^\/?[^\/]*/)[0], 
            a = a.substr(c.length), b += c);
            return b;
        }
        this.scheme = null, this.authority = null, this.path = "", this.query = null, this.fragment = null, 
        this.parse = function(a) {
            var b = a.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
            return this.scheme = b[3] ? b[2] : null, this.authority = b[5] ? b[6] : null, this.path = b[7], 
            this.query = b[9] ? b[10] : null, this.fragment = b[12] ? b[13] : null, this;
        }, this.toString = function() {
            var a = "";
            return null !== this.scheme && (a = a + this.scheme + ":"), null !== this.authority && (a = a + "//" + this.authority), 
            null !== this.path && (a += this.path), null !== this.query && (a = a + "?" + this.query), 
            null !== this.fragment && (a = a + "#" + this.fragment), a;
        }, this.toAbsolute = function(a) {
            var c, d;
            return a = new jscolor.URI(a), c = this, d = new jscolor.URI(), null === a.scheme ? !1 : (null !== c.scheme && c.scheme.toLowerCase() === a.scheme.toLowerCase() && (c.scheme = null), 
            null !== c.scheme ? (d.scheme = c.scheme, d.authority = c.authority, d.path = b(c.path), 
            d.query = c.query) : (null !== c.authority ? (d.authority = c.authority, d.path = b(c.path), 
            d.query = c.query) : ("" === c.path ? (d.path = a.path, d.query = null !== c.query ? c.query : a.query) : ("/" === c.path.substr(0, 1) ? d.path = b(c.path) : (d.path = null !== a.authority && "" === a.path ? "/" + c.path : a.path.replace(/[^\/]+$/, "") + c.path, 
            d.path = b(d.path)), d.query = c.query), d.authority = a.authority), d.scheme = a.scheme), 
            d.fragment = c.fragment, d);
        }, a && this.parse(a);
    },
    color: function(a, b) {
        function d(a, b, c) {
            var g, d = Math.min(Math.min(a, b), c), e = Math.max(Math.max(a, b), c), f = e - d;
            return 0 === f ? [ null, 0, e ] : (g = a === d ? 3 + (c - b) / f : b === d ? 5 + (a - c) / f : 1 + (b - a) / f, 
            [ 6 === g ? 0 : g, f / e, e ]);
        }
        function e(a, b, c) {
            var d, e, f, g;
            if (null === a) return [ c, c, c ];
            switch (d = Math.floor(a), e = d % 2 ? a - d : 1 - (a - d), f = c * (1 - b), g = c * (1 - b * e), 
            d) {
              case 6:
              case 0:
                return [ c, g, f ];

              case 1:
                return [ g, c, f ];

              case 2:
                return [ f, c, g ];

              case 3:
                return [ f, g, c ];

              case 4:
                return [ g, f, c ];

              case 5:
                return [ c, f, g ];
            }
        }
        function f() {
            delete jscolor.picker.owner, document.getElementsByTagName("body")[0].removeChild(jscolor.picker.boxB);
        }
        function g(b, c) {
            var d, e, f, g, k;
            if (!jscolor.picker) {
                for (jscolor.picker = {
                    box: document.createElement("div"),
                    boxB: document.createElement("div"),
                    pad: document.createElement("div"),
                    padB: document.createElement("div"),
                    padM: document.createElement("div"),
                    sld: document.createElement("div"),
                    sldB: document.createElement("div"),
                    sldM: document.createElement("div")
                }, d = 0, e = 4; d < jscolor.images.sld[1]; d += e) f = document.createElement("div"), 
                f.style.height = e + "px", f.style.fontSize = "1px", f.style.lineHeight = "0", jscolor.picker.sld.appendChild(f);
                jscolor.picker.sldB.appendChild(jscolor.picker.sld), jscolor.picker.box.appendChild(jscolor.picker.sldB), 
                jscolor.picker.box.appendChild(jscolor.picker.sldM), jscolor.picker.padB.appendChild(jscolor.picker.pad), 
                jscolor.picker.box.appendChild(jscolor.picker.padB), jscolor.picker.box.appendChild(jscolor.picker.padM), 
                jscolor.picker.boxB.appendChild(jscolor.picker.box);
            }
            g = jscolor.picker, v = [ b + o.pickerBorder + o.pickerFace + o.pickerInset, c + o.pickerBorder + o.pickerFace + o.pickerInset ], 
            w = [ null, c + o.pickerBorder + o.pickerFace + o.pickerInset ], g.box.onmouseup = g.box.onmouseout = function() {
                a.focus();
            }, g.box.onmousedown = function() {
                q = !0;
            }, g.box.onmousemove = function(a) {
                t && m(a), u && n(a);
            }, g.padM.onmouseup = g.padM.onmouseout = function() {
                t && (t = !1, jscolor.fireEvent(r, "change"));
            }, g.padM.onmousedown = function(a) {
                t = !0, m(a);
            }, g.sldM.onmouseup = g.sldM.onmouseout = function() {
                u && (u = !1, jscolor.fireEvent(r, "change"));
            }, g.sldM.onmousedown = function(a) {
                u = !0, n(a);
            }, g.box.style.width = 4 * o.pickerInset + 2 * o.pickerFace + jscolor.images.pad[0] + 2 * jscolor.images.arrow[0] + jscolor.images.sld[0] + "px", 
            g.box.style.height = 2 * o.pickerInset + 2 * o.pickerFace + jscolor.images.pad[1] + "px", 
            g.boxB.style.position = "absolute", g.boxB.style.clear = "both", g.boxB.style.left = b + "px", 
            g.boxB.style.top = c + "px", g.boxB.style.zIndex = o.pickerZIndex, g.boxB.style.border = o.pickerBorder + "px solid", 
            g.boxB.style.borderColor = o.pickerBorderColor, g.boxB.style.background = o.pickerFaceColor, 
            g.pad.style.width = jscolor.images.pad[0] + "px", g.pad.style.height = jscolor.images.pad[1] + "px", 
            g.padB.style.position = "absolute", g.padB.style.left = o.pickerFace + "px", g.padB.style.top = o.pickerFace + "px", 
            g.padB.style.border = o.pickerInset + "px solid", g.padB.style.borderColor = o.pickerInsetColor, 
            g.padM.style.position = "absolute", g.padM.style.left = "0", g.padM.style.top = "0", 
            g.padM.style.width = o.pickerFace + 2 * o.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + "px", 
            g.padM.style.height = g.box.style.height, g.padM.style.cursor = "crosshair", g.sld.style.overflow = "hidden", 
            g.sld.style.width = jscolor.images.sld[0] + "px", g.sld.style.height = jscolor.images.sld[1] + "px", 
            g.sldB.style.position = "absolute", g.sldB.style.right = o.pickerFace + "px", g.sldB.style.top = o.pickerFace + "px", 
            g.sldB.style.border = o.pickerInset + "px solid", g.sldB.style.borderColor = o.pickerInsetColor, 
            g.sldM.style.position = "absolute", g.sldM.style.right = "0", g.sldM.style.top = "0", 
            g.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + o.pickerFace + 2 * o.pickerInset + "px", 
            g.sldM.style.height = g.box.style.height;
            try {
                g.sldM.style.cursor = "pointer";
            } catch (j) {
                g.sldM.style.cursor = "hand";
            }
            switch (p) {
              case 0:
                k = colorPrePath + "libs/images/formEle/hs.png";
                break;

              case 1:
                k = +colorPrePath + "libs/images/formEle/hv.png";
            }
            g.padM.style.background = "url(" + colorPrePath + "libs/images/formEle/cross.gif) no-repeat", 
            g.sldM.style.background = "url(" + colorPrePath + "libs/images/formEle/arrow.gif) no-repeat", 
            g.pad.style.background = "url('" + k + "') 0 0 no-repeat", h(), i(), jscolor.picker.owner = o, 
            document.getElementsByTagName("body")[0].appendChild(g.boxB);
        }
        function h() {
            var a, b, c, d, f, g, h, i, j;
            switch (p) {
              case 0:
                a = 1;
                break;

              case 1:
                a = 2;
            }
            switch (b = Math.round(o.hsv[0] / 6 * (jscolor.images.pad[0] - 1)), c = Math.round((1 - o.hsv[a]) * (jscolor.images.pad[1] - 1)), 
            jscolor.picker.padM.style.backgroundPosition = o.pickerFace + o.pickerInset + b - Math.floor(jscolor.images.cross[0] / 2) + "px " + (o.pickerFace + o.pickerInset + c - Math.floor(jscolor.images.cross[1] / 2)) + "px", 
            d = jscolor.picker.sld.childNodes, p) {
              case 0:
                for (f = e(o.hsv[0], o.hsv[1], 1), g = 0; g < d.length; g += 1) d[g].style.backgroundColor = "rgb(" + 100 * f[0] * (1 - g / d.length) + "%," + 100 * f[1] * (1 - g / d.length) + "%," + 100 * f[2] * (1 - g / d.length) + "%)";
                break;

              case 1:
                switch (i = [ o.hsv[2], 0, 0 ], g = Math.floor(o.hsv[0]), j = g % 2 ? o.hsv[0] - g : 1 - (o.hsv[0] - g), 
                g) {
                  case 6:
                  case 0:
                    f = [ 0, 1, 2 ];
                    break;

                  case 1:
                    f = [ 1, 0, 2 ];
                    break;

                  case 2:
                    f = [ 2, 0, 1 ];
                    break;

                  case 3:
                    f = [ 2, 1, 0 ];
                    break;

                  case 4:
                    f = [ 1, 2, 0 ];
                    break;

                  case 5:
                    f = [ 0, 2, 1 ];
                }
                for (g = 0; g < d.length; g += 1) h = 1 - 1 / (d.length - 1) * g, i[1] = i[0] * (1 - h * j), 
                i[2] = i[0] * (1 - h), d[g].style.backgroundColor = "rgb(" + 100 * i[f[0]] + "%," + 100 * i[f[1]] + "%," + 100 * i[f[2]] + "%)";
            }
        }
        function i() {
            var a, b;
            switch (p) {
              case 0:
                a = 2;
                break;

              case 1:
                a = 1;
            }
            b = Math.round((1 - o.hsv[a]) * (jscolor.images.sld[1] - 1)), jscolor.picker.sldM.style.backgroundPosition = "0 " + (o.pickerFace + o.pickerInset + b - Math.floor(jscolor.images.arrow[1] / 2)) + "px";
        }
        function j() {
            return jscolor.picker && jscolor.picker.owner === o;
        }
        function k() {
            r === a && o.importColor(), o.pickerOnfocus && o.hidePicker();
        }
        function l() {
            r !== a && o.importColor();
        }
        function m(a) {
            var b = jscolor.getMousePos(a), c = b[0] - v[0], d = b[1] - v[1];
            switch (p) {
              case 0:
                o.fromHSV(c * (6 / (jscolor.images.pad[0] - 1)), 1 - d / (jscolor.images.pad[1] - 1), null, A);
                break;

              case 1:
                o.fromHSV(c * (6 / (jscolor.images.pad[0] - 1)), null, 1 - d / (jscolor.images.pad[1] - 1), A);
            }
        }
        function n(a) {
            var b = jscolor.getMousePos(a), c = b[1] - v[1];
            switch (p) {
              case 0:
                o.fromHSV(null, null, 1 - c / (jscolor.images.sld[1] - 1), z);
                break;

              case 1:
                o.fromHSV(null, 1 - c / (jscolor.images.sld[1] - 1), null, z);
            }
        }
        var c, o, p, q, r, s, t, u, v, w, x, y, z, A, B;
        this.required = !0, this.adjust = !0, this.hash = !1, this.caps = !0, this.valueElement = a, 
        this.styleElement = a, this.hsv = [ 0, 0, 1 ], this.rgb = [ 1, 1, 1 ], this.pickerOnfocus = !0, 
        this.pickerMode = "HSV", this.pickerPosition = "bottom", this.pickerFace = 10, this.pickerFaceColor = "ThreeDFace", 
        this.pickerBorder = 1, this.pickerBorderColor = "ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight", 
        this.pickerInset = 1, this.pickerInsetColor = "ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow", 
        this.pickerZIndex = 1e4;
        for (c in b) b.hasOwnProperty(c) && (this[c] = b[c]);
        switch (this.hidePicker = function() {
            j() && f();
        }, this.showPicker = function() {
            var b, c, d, e, f, h, i, k, l, m;
            if (!j()) {
                switch (b = jscolor.getElementPos(a), c = jscolor.getElementSize(a), d = jscolor.getViewPos(), 
                e = jscolor.getViewSize(), f = [ 2 * this.pickerBorder + 4 * this.pickerInset + 2 * this.pickerFace + jscolor.images.pad[0] + 2 * jscolor.images.arrow[0] + jscolor.images.sld[0], 2 * this.pickerBorder + 2 * this.pickerInset + 2 * this.pickerFace + jscolor.images.pad[1] ], 
                this.pickerPosition.toLowerCase()) {
                  case "left":
                    h = 1, i = 0, k = -1;
                    break;

                  case "right":
                    h = 1, i = 0, k = 1;
                    break;

                  case "top":
                    h = 0, i = 1, k = -1;
                    break;

                  default:
                    h = 0, i = 1, k = 1;
                }
                l = (c[i] + f[i]) / 2, m = [ -d[h] + b[h] + f[h] > e[h] ? -d[h] + b[h] + c[h] / 2 > e[h] / 2 && b[h] + c[h] - f[h] >= 0 ? b[h] + c[h] - f[h] : b[h] : b[h], -d[i] + b[i] + c[i] + f[i] - l + l * k > e[i] ? -d[i] + b[i] + c[i] / 2 > e[i] / 2 && b[i] + c[i] - l - l * k >= 0 ? b[i] + c[i] - l - l * k : b[i] + c[i] - l + l * k : b[i] + c[i] - l + l * k >= 0 ? b[i] + c[i] - l + l * k : b[i] + c[i] - l - l * k ], 
                g(m[h], m[i]);
            }
        }, this.importColor = function() {
            r ? this.adjust ? !this.required && /^\s*$/.test(r.value) ? (r.value = "", s.style.backgroundColor = s.jscStyle.backgroundColor, 
            s.style.color = s.jscStyle.color, this.exportColor(x | y)) : this.fromString(r.value) || this.exportColor() : this.fromString(r.value, x) || (s.style.backgroundColor = s.jscStyle.backgroundColor, 
            s.style.color = s.jscStyle.color, this.exportColor(x | y)) : this.exportColor();
        }, this.exportColor = function(a) {
            if (!(a & x) && r) {
                var b = this.toString();
                this.caps && (b = b.toUpperCase()), this.hash && (b = "#" + b), r.value = b;
            }
            a & y || !s || (s.style.backgroundColor = "#" + this.toString(), s.style.color = .213 * this.rgb[0] + .715 * this.rgb[1] + .072 * this.rgb[2] < .5 ? "#FFF" : "#000"), 
            a & z || !j() || h(), a & A || !j() || i();
        }, this.fromHSV = function(a, b, c, d) {
            0 > a && (a = 0) || a > 6 && (a = 6), 0 > b && (b = 0) || b > 1 && (b = 1), 0 > c && (c = 0) || c > 1 && (c = 1), 
            this.rgb = e(null === a ? this.hsv[0] : this.hsv[0] = a, null === b ? this.hsv[1] : this.hsv[1] = b, null === c ? this.hsv[2] : this.hsv[2] = c), 
            this.exportColor(d);
        }, this.fromRGB = function(a, b, c, e) {
            0 > a && (a = 0) || a > 1 && (a = 1), 0 > b && (b = 0) || b > 1 && (b = 1), 0 > c && (c = 0) || c > 1 && (c = 1);
            var f = d(null === a ? this.rgb[0] : this.rgb[0] = a, null === b ? this.rgb[1] : this.rgb[1] = b, null === c ? this.rgb[2] : this.rgb[2] = c);
            null !== f[0] && (this.hsv[0] = f[0]), 0 !== f[2] && (this.hsv[1] = f[1]), this.hsv[2] = f[2], 
            this.exportColor(e);
        }, this.fromString = function(a, b) {
            var c = a.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
            return c ? (6 === c[1].length ? this.fromRGB(parseInt(c[1].substr(0, 2), 16) / 255, parseInt(c[1].substr(2, 2), 16) / 255, parseInt(c[1].substr(4, 2), 16) / 255, b) : this.fromRGB(parseInt(c[1].charAt(0) + c[1].charAt(0), 16) / 255, parseInt(c[1].charAt(1) + c[1].charAt(1), 16) / 255, parseInt(c[1].charAt(2) + c[1].charAt(2), 16) / 255, b), 
            !0) : !1;
        }, this.toString = function() {
            return (256 | Math.round(255 * this.rgb[0])).toString(16).substr(1) + (256 | Math.round(255 * this.rgb[1])).toString(16).substr(1) + (256 | Math.round(255 * this.rgb[2])).toString(16).substr(1);
        }, o = this, p = "hvs" === this.pickerMode.toLowerCase() ? 1 : 0, q = !1, r = jscolor.fetchElement(this.valueElement), 
        s = jscolor.fetchElement(this.styleElement), t = !1, u = !1, x = 1, y = 2, z = 4, 
        A = 8, jscolor.addEvent(a, "focus", function() {
            o.pickerOnfocus && o.showPicker();
        }), jscolor.addEvent(a, "blur", function() {
            q ? q = !1 : window.setTimeout(function() {
                q || k(), q = !1;
            }, 0);
        }), r && (B = function() {
            o.fromString(r.value, x);
        }, jscolor.addEvent(r, "keyup", B), jscolor.addEvent(r, "input", B), jscolor.addEvent(r, "blur", l), 
        r.setAttribute("autocomplete", "off")), s && (s.jscStyle = {
            backgroundColor: s.style.backgroundColor,
            color: s.style.color
        }), p) {
          case 0:
            jscolor.requireImage("hs.png");
            break;

          case 1:
            jscolor.requireImage("hv.png");
        }
        jscolor.requireImage("cross.gif"), jscolor.requireImage("arrow.gif"), this.importColor();
    }
};